package com.film.admincontroller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.film.domain.Director;
import com.film.domain.Film;
import com.film.domain.FilmType;
import com.film.domain.Performer;
import com.film.service.DirectorService;
import com.film.service.FilmService;
import com.film.service.FilmTypeService;
import com.film.service.PerformerService;
import com.film.service.impl.DirectorServiceImpl;
import com.film.service.impl.FilmServiceImpl;
import com.film.service.impl.FilmTypeServiceImpl;
import com.film.service.impl.PerformerServiceImpl;
/**
 * 该控制类用来做后台热梦电影信息展示
 * @author 2119196781
 *
 */
@WebServlet("/adminHotFilm.do")
public class HotFilmController extends HttpServlet {
	private FilmService filmService = new FilmServiceImpl();
	private FilmTypeService filmTypeService = new FilmTypeServiceImpl();
	private DirectorService directorService = new DirectorServiceImpl();
	private PerformerService performerService = new PerformerServiceImpl();
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		//先查询所有的电影信息、
		List<Film> adminHotFilms = filmService.selectHotFilm();
		//查询所有的类型
		List<FilmType> admiFilmTypes = filmTypeService.selectAllFilmType();
		session.setAttribute("admiFilmTypes", admiFilmTypes);
		//查询所有导演的信息
		List<Director> adminFilmDirectors = directorService.selectAllDirector();
		session.setAttribute("adminFilmDirectors", adminFilmDirectors);
		//查询所有的演员
		List<Performer> adminFilmPerformers = performerService.selectAllPerformer();
		session.setAttribute("adminFilmPerformers", adminFilmPerformers);
		//存所有的电影信息
		session.setAttribute("adminHotFilms", adminHotFilms);
		session.setAttribute("offTheShelfFilm", adminHotFilms);
		//用来存所有热门电影的个数、
		session.setAttribute("hotFilmsSize", adminHotFilms.size());
		response.sendRedirect("admin_jsp/hotFilmExhibition.jsp?flag=1");
		
//		request.getRequestDispatcher("admin_jsp/filmAdministration.jsp").forward(request, response);
	}
}
